//
//  ScrollTimingView.m
//  TabulaImaginarius2
//
//  Created by TA2 on 5/5/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "ScrollTimingView.h"


@implementation ScrollTimingView

@synthesize nextView;

- (void)dealloc {
    [nextView release];
    nextView = nil;
    [super dealloc];
}

- (void)awakeFromNib {
	self.showsVerticalScrollIndicator = NO;
	self.showsHorizontalScrollIndicator = NO;
	self.multipleTouchEnabled = YES;
	self.bouncesZoom = YES;
	self.scrollEnabled = NO;
	self.delegate = self;
	
	for (UIGestureRecognizer *gr in self.gestureRecognizers)  {     
		if ([gr isKindOfClass:[UIPanGestureRecognizer class]]) {
			UIPanGestureRecognizer *pgr = (UIPanGestureRecognizer *) gr;
			pgr.enabled = NO;
		}   
	}
	
	for (UIGestureRecognizer *gr in self.gestureRecognizers)  {     
		if ([gr isKindOfClass:[UIPinchGestureRecognizer class]]) {
			if ([nextView.nextView isKindOfClass:[MapScrollView class]]) {
				((MapScrollView *)nextView.nextView).zoomGesture = (UIPinchGestureRecognizer *) gr;
			}
			if ([nextView.nextView isKindOfClass:[SelectionScrollView class]]) {
				((SelectionScrollView *)nextView.nextView).zoomGesture = (UIPinchGestureRecognizer *) gr;
			}
		}   
	}
}

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
	return [super hitTest:point withEvent:event];
}

- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale {
	if ([nextView.nextView isKindOfClass:[MapScrollView class]]) {
		[((MapScrollView *)nextView.nextView) activateScroll];
	}
}

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
    return self; //.nextView.nextView;
}

- (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view {
	return YES;
}

@end
